// RichEditDS.cpp : implementation file
//

#include "stdafx.h"
#include "MLS.h"
#include "RichEditDS.h"
#include <AfxPriv.h>


// CRichEditDS

IMPLEMENT_DYNAMIC(CRichEditDS, CRichEditCtrl)
CRichEditDS::CRichEditDS()
{
}

CRichEditDS::~CRichEditDS()
{
}

void CRichEditDS::StreamString(const CStringA str)
{
	EDITSTREAM es = {(DWORD)&str, 0, EditStreamCallBack};
	StreamIn(SF_RTF, es);
}

DWORD CALLBACK CRichEditDS::EditStreamCallBack(DWORD dwCookie,
	LPBYTE pbBuff, LONG cb,	LONG *pcb)
{
	CStringA *pstr = (CStringA *)dwCookie;

	if( pstr->GetLength() < cb )
	{
		*pcb = pstr->GetLength();
		memcpy(pbBuff, (LPCSTR) *pstr, *pcb );
		pstr->Empty();
	}
	else
	{
		*pcb = cb;
		memcpy(pbBuff, (LPCSTR) *pstr, *pcb );
		*pstr = pstr->Right( pstr->GetLength() - cb );
	}
	return 0;
}


BEGIN_MESSAGE_MAP(CRichEditDS, CRichEditCtrl)
END_MESSAGE_MAP()



// CRichEditDS message handlers

